package view;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JComboBox;

import model.Role;
import model.State;

/**
 * @author Kevin Anderson
 *
 */
public class RoleListener implements ActionListener{

	private State my_state;
	

	public RoleListener()
	{
		super();
	}
	
	public void setState(State the_state)
	{
		my_state = the_state;
	}


	@Override
	public void actionPerformed(ActionEvent e) {
		
		if (((JComboBox) e.getSource()).getItemCount() > 0)
		{
			my_state.allowLogin(true);
			my_state.setRole((Role) ((JComboBox) e.getSource()).getSelectedItem());
		} else {
			my_state.allowLogin(false);
		}		
	}
}